//
//  MyEvaluationCell.m
//  NtoccShipper
//
//  Created by mac on 2019/12/19.
//  Copyright © 2019 zhuchongjin. All rights reserved.
//

#import "MyEvaluationCell.h"
#import "HCSStarRatingView.h"
//#import "XLImageViewer.h"

@interface MyEvaluationCell(){
    UIView *_imgParent;
}
@property (nonatomic,strong) CJLabel *labName;
@property (nonatomic,strong) HCSStarRatingView *viewRate;
@property (nonatomic,strong) CJView *viewStar;
@property (nonatomic,strong) CJLabel *labStarNum;
@property (nonatomic,strong) CJLabel *labTime;
@property (nonatomic,strong) CJLabel *labOrderNum;
@property (nonatomic,strong) CJLabel *labRemark;
@property (nonatomic,strong) NSMutableArray * arrNetImgs;
@property (nonatomic,strong) CJLabel *labTimeNew;
@end

@implementation MyEvaluationCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (void)setCellInfoWithModel:(MyEvaluationModel *)model isShippment:(NSString *)strType{
    // self.strEvaluation = @"0";  我评价   1 评价我
    
    if (strType.intValue == 0) {
        self.viewRate.value = model.avgBasicGrade;
        self.labStarNum.text = CJStringWithFormat(@"%0.1f",model.avgBasicGrade);
    }else{
        self.viewRate.value = model.avgShipBasicGrade;
        self.labStarNum.text = CJStringWithFormat(@"%0.1f",model.avgShipBasicGrade);
    }
    
    self.labName.text = model.driverName;
    [self.viewStar addSubview:self.viewRate];
//    self.viewRate.value = model.avgBasicGrade;
//    self.labStarNum.text = CJStringWithFormat(@"%0.1f",model.avgBasicGrade);
    
    if ([CJControl getUIWithNew]) {
        self.labTimeNew.hidden = NO;
        self.labTime.hidden = YES;
        self.labTimeNew.text = model.gmtCreated;
    }else{
        self.labTime.hidden = NO;
        self.labTimeNew.hidden = YES;
        self.labTime.text = model.gmtCreated;
    }
    
    self.labOrderNum.text = CJStringWithFormat(@"订单号:%@",model.orderDetailNumber);
    self.labRemark.text = model.commentContent;
  
    [_imgParent removeAllSubviews];
    if (self.arrNetImgs.count > 0) {
        [self.arrNetImgs removeAllObjects];
    }
    NSArray *list = model.imageUrlList;
    if (list.count > 0) {
        [self.arrNetImgs addObjectsFromArray:list];
    }
    for (int i = 0; i < self.arrNetImgs.count; i++) {
        
        UIImageView* cell = [[UIImageView alloc]init];
        cell.userInteractionEnabled = YES;

        //         UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickToSeeBigCell:)];
        cell.tag = i + 1000;
        [cell enableFlexLayout:YES];
//        [cell addGestureRecognizer:tap];
        
        [cell setLayoutAttrStrings:@[
                                     @"width",@"75",
                                     @"height",@"75",
                                     @"margin",@"1%",
                                     @"alignItems",@"center",
                                     @"justifyContent",@"center",
                                     ]];
        [cell setViewAttr:@"bgColor" Value:@"#E4E9ED"];
        [cell setViewAttr:@"borderRadius" Value:@"0"];
        [_imgParent insertSubview:cell atIndex:i];
        [_imgParent markDirty];
    //    cell.layer.contents = (id) img.CGImage;
    //    UIImageView *imgV;
        [cell sd_setImageWithURL:[NSURL URLWithString:self.arrNetImgs[i]] placeholderImage:[UIImage imageNamed:@"zcj_error_image"]];
    
    }
}

//-(void)clickToSeeBigCell:(UIGestureRecognizer*)sender{
//    UIView* cell = sender.view;
//    [[XLImageViewer shareInstanse] showNetImages:self.arrNetImgs index:(int)cell.tag - 1000 fromImageContainer:cell];
//}

- (NSMutableArray *)arrNetImgs{
    if (!_arrNetImgs) {
        _arrNetImgs = [[NSMutableArray alloc]init];
    }
    return _arrNetImgs;
}

- (HCSStarRatingView *)viewRate{
    if (!_viewRate) {
      _viewRate =   [[HCSStarRatingView alloc]initWithFrame:CGRectMake(0,0,110,30)];
        _viewRate.tintColor = [UIColor cjStarRateColor];
        _viewRate.starBorderColor = [UIColor cjClearColor];
        _viewRate.emptyStarColor = [UIColor cjEmptyStarRateColor];
        _viewRate.backgroundColor = [UIColor cjClearColor];
        _viewRate.enabled = NO;
        _viewRate.allowsHalfStars = YES;
        _viewRate.maximumValue = 5;
        _viewRate.minimumValue = 0;
    }
    return  _viewRate;
}
@end
